package com.kingland.neusoft.course.service;

import com.kingland.neusoft.course.mapper.BorrowMapper;
import com.kingland.neusoft.course.mapper.dao.BorrowList;
import com.kingland.neusoft.course.mapper.dao.BorrowModel;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BorrowService {
    private final BorrowMapper borrowMapper;

    public BorrowService(BorrowMapper borrowMapper) {
        this.borrowMapper = borrowMapper;
    }

    public void BorrowBook(BorrowModel borrowModel){
        borrowMapper.addBorrowInfo(borrowModel);
    }

    public void ReturnBook(Long borrowId){
        borrowMapper.deleteBorrowInfoByBorrowId(borrowId);
    }

    public List<BorrowList> GetAllBorrowBook(Long BorrowUserId){
        return borrowMapper.selectBorrowUserById(BorrowUserId);
    }

    public int count(){
        return borrowMapper.count();
    }
}
